package  
{
	import flash.display.MovieClip;

	/**
	 * ...
	 * @author Rodrigo Forti & Rafael Bringel
	 */
	public class Level1 extends Level_Base
	{			
		private var nave : Nave;
		private var background : FlashingBackground;
		private var bola : Bola;
		private var bricks : Bricks;
		private var logo : MovieClip;
		//private var texto : MovieClip;
		
		public override function start():void
		{	
			background = new FlashingBackground();
			nave = new Nave();
			
			logo = new Logo();
			logo.x = Main.Self.stage.stageWidth / 2;
			Main.Self.screen.addChild(logo);
			
			//texto = new Texto()
			//texto.x = Main.Self.stage.stageWidth / 2;
			//texto.y = Main.Self.stage.stageHeight - 180;
			//texto.alpha = 2;
			//Main.Self.screen.addChild(texto);
			
			
			bola = new Bola();
			
			bricks = new Bricks(
									[
										//
										//[0, 0],
										//[0, 0]
										[1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1],
										[1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1], 
										[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
										[2, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2],
										[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
									]
								);
								

			SoundManager.stopSound("fundo");
			SoundManager.playLoopedSound("fundo");
			SoundManager.playLoopedSound("gameLoop");
			
			
		}
		
		public override function update():void
		{
			nave.update();
			background.update();
			bola.update();
			bola.verifyCollisionWithNave(nave);
			bola.verifyCollisionWithBrick(bricks.brickMap);
			
			//if (texto.alpha > 0)
			//	texto.alpha -= 0.01;
		}
		
		public override function terminate():void
		{
			//SoundManager.stopSound("fundo");
			
			SoundManager.stopSound("gameLoop");
			nave.destroy();
			background.destroy();
			bricks.destroy();
			Main.Self.screen.removeChild(logo);
		}
		
	}

}